//
//  YNSReusableHeadView.m
//  HNBaseProject
//
//  Created by TR on 2024/7/19.
//

#import "YNSReusableHeadView.h"

@implementation YNSReusableHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self =[super initWithFrame:frame])
    {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.topImageV];
        [self addSubview:self.tipImageV];
        [self addSubview:self.topBtn];
        [self addSubview:self.tLab];
        [self addSubview:self.cLab];
        
        [self.topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(0);
            make.left.offset(15);
            make.right.offset(-15);
            make.height.offset(kRealValue(435));
        }];
        [self.tipImageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.topImageV.mas_top).offset(20);
            make.left.equalTo(self.topImageV.mas_left).offset(15);
            make.width.offset(kRealValue(115));
            make.height.offset(kRealValue(24));
        }];
        [self.topBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.topImageV.mas_centerX).offset(0);
            make.bottom.equalTo(self.topImageV.mas_bottom).offset(-54);
            make.width.offset(kRealValue(200));
            make.height.offset(40);
        }];
        [self.tLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.top.equalTo(self.topImageV.mas_bottom).offset(35);
        }];
        [self.cLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.tLab.mas_bottom).offset(7);
            make.left.offset(15);
        }];
    }
    return self;
}
- (UIImageView*)topImageV{
    if (!_topImageV)
    {
        _topImageV = [[UIImageView alloc]init];
        _topImageV.contentMode = UIViewContentModeScaleAspectFill;
        _topImageV.image = [UIImage imageNamed:@"home_bg"];
    }
    return _topImageV;
}
- (UIImageView*)tipImageV{
    if (!_tipImageV)
    {
        _tipImageV = [[UIImageView alloc]init];
        _tipImageV.contentMode = UIViewContentModeScaleToFill;
        _tipImageV.image = [UIImage imageNamed:@"home_tips"];
    }
    return _tipImageV;
}
- (UIButton*)topBtn {
    if(!_topBtn){
        
        _topBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_topBtn setTitle:LKLocalizedString(@"立即制作") forState:UIControlStateNormal];
        _topBtn.backgroundColor = [UIColor colorWithHexString:@"#000000"];
        _topBtn.layer.masksToBounds = YES;
        _topBtn.layer.cornerRadius = 20;
//        _topBtn.layer.borderWidth = 2;
//        _topBtn.layer.borderColor = [UIColor colorWithHexString:@"#B3F7FF"].CGColor;
        [_topBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_topBtn addTarget:self action:@selector(startClick) forControlEvents:UIControlEventTouchUpInside];
        _topBtn.titleLabel.font = PFRFontSemibold(16);
    }
    return _topBtn;
}
- (UILabel*)tLab {
    if (!_tLab)
    {
        _tLab = [[UILabel alloc]init];
        _tLab.textColor = [UIColor colorWithHexString:@"#000000"];
        _tLab.font = PFRFontSemibold(20);
        _tLab.text = NSLocalizedString(@"大家正在做",nil);//@"大家正在做";
    }
    return _tLab;
}

- (UILabel*)cLab {
    if (!_cLab)
    {
        _cLab = [[UILabel alloc]init];
        _cLab.textColor = [UIColor colorWithHexString:@"#9A9A9A"];
        _cLab.font = [UIFont systemFontOfSize:13];
        _cLab.text = NSLocalizedString(@"寻找", nil) ;
    }
    return _cLab;
}
#pragma mark----开始制作-----
- (void)startClick {
    if (self.startblock)
    {
        self.startblock();
    }
}
@end
